CREATE TABLE [dbo].[PrescriptionDetail]
(
[PrescriptionDetailId] [bigint] NOT NULL IDENTITY(1, 1),
[PrescriptionID] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[DrugId] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[DrugName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Unit] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Quantity] [int] NOT NULL,
[CostPrice] [decimal] (12, 0) NOT NULL,
[UnitPrice] [decimal] (12, 0) NOT NULL CONSTRAINT [DF_PrescriptionDetail_UnitPrice] DEFAULT ((0)),
[ExpDate] [datetime] NULL,
[BatchLot] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IsControlDrug] [bit] NOT NULL CONSTRAINT [DF_PrescriptionDetail_IsControlDrug] DEFAULT ((0)),
[Remark] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PrescriptionDetail] ADD CONSTRAINT [PK_PrescriptionDetail] PRIMARY KEY CLUSTERED  ([PrescriptionDetailId]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PrescriptionDetail] ADD CONSTRAINT [FK_PrescriptionDetail_DrugDispo] FOREIGN KEY ([DrugId]) REFERENCES [dbo].[DrugDispo] ([DrugId])
GO
ALTER TABLE [dbo].[PrescriptionDetail] ADD CONSTRAINT [FK_PrescriptionDetail_Prescription] FOREIGN KEY ([PrescriptionID]) REFERENCES [dbo].[Prescription] ([PrescriptionID])
GO
